package com.iona.servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.iona.dao.DisciplineDAO;
import com.iona.dao.PurviewDAO;
import com.iona.domain.Discipline;
import com.iona.domain.Purview;
import com.iona.json.JSONException;
import com.iona.json.builders.PivotBuilder;

@WebServlet("/list")
public class PivotFeederServlet extends FeederServlet {

	private static final long serialVersionUID = 7408976873597973074L;

	@Override
	public Object doFeed(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException,
			JSONException {
		List<Discipline> disciplines = new DisciplineDAO().findAll();
		List<Purview> purviews = new PurviewDAO().findAll();
		Object build = new PivotBuilder(disciplines, purviews).build();
		return build;
	}

}
